﻿using Cordyceps.EntityFrameworkCore;
using Cordyceps.Micro.AuthServer.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Cordyceps.Micro.AuthServer.SqlServer.DbMigrator.EFCore;

public class AuthMigrationsDbContext : CordycepsDbContextBase<AuthMigrationsDbContext>
{
    /// <summary>
    ///     构造函数
    /// </summary>
    /// <param name="options"></param>
    public AuthMigrationsDbContext(DbContextOptions<AuthMigrationsDbContext> options)
        : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        // 配置迁移历史表不使用双引号（即使用小写）
        modelBuilder.Entity<HistoryRow>().ToTable("__efmigrationshistory", t => t.ExcludeFromMigrations());

        base.OnModelCreating(modelBuilder);

        modelBuilder.ConfigureAuthServer();
    }
}